import React, { useState,useEffect } from 'react'
import { Space, Table, Tag } from 'antd'
import type { ColumnsType } from 'antd/es/table'
import axios from 'axios'

interface DataType {
  key: string
  name: string
  age: number
  address: string
  tags: string[]
}

const columns: ColumnsType<DataType> = [
  {
    title: 'Name',
    dataIndex: 'name',
    key: 'name',
    render: (text) => <a>{text}</a>,
  },
  {
    title: 'Age',
    dataIndex: 'age',
    key: 'age',
  },
  {
    title: 'Address',
    dataIndex: 'address',
    key: 'address',
  },
  {
    title: 'Tags',
    key: 'tags',
    dataIndex: 'tags',
  },
  {
    title: 'Action',
    key: 'action',
    render: (_, record) => (
      <Space size="middle">
        <a>编辑</a>
        <a>删除</a>
      </Space>
    ),
  },
]


const Home: React.FC = () => {
  const [list,setList]=useState([])
  useEffect(()=>{
    axios.get('/api/list').then((res)=>{
      const resp=res.data.data
      setList(resp)
    })
  },[])
  const data: DataType[] = [
    {
      list.map((v,i)=>{
        return(
          
        )
      })
    }
  ]
  return <Table columns={columns} dataSource={data} />}

export default Home
